package org.jeecg.cn.edu.scau.vm.common.consts;

import org.jeecg.cn.edu.scau.vm.review.enums.VmScheduleEnum;

import java.util.HashMap;
import java.util.Map;

public class ScheduleConst {

    private static volatile Map<Integer, VmScheduleEnum> statusMap;

    public static VmScheduleEnum getEnumByCode(Integer code) {
        // 单例模式构造枚举map
        if (statusMap == null) {
            synchronized (ScheduleConst.class) {
                if (statusMap == null) {
                    // 构造map
                    VmScheduleEnum[] values = VmScheduleEnum.values();
                    statusMap = new HashMap<>(values.length);
                    for (VmScheduleEnum value : values) {
                        statusMap.put(value.getCode(), value);
                    }
                }
            }
        }
        return statusMap.get(code);
    }
}
